﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevTeam;

using System;
namespace ConfExpert.Forms.SatinAlma
{
    public partial class CustomerStockAging : XForm
    {
        public CustomerStockAging()
        {
            InitializeComponent();
        }

        private void VendorPerformance_Load(object sender, EventArgs e)
        {

            gridView1.Init("GetAges", 0);
            gridView1.AddDetailGrid(gridView2, "ProductId");

            gridView1.FormatAsNumber(1, "AgeInYrs", "StokQty", "CikanQty");
            gridView1.Columns["AgeInYrs"].DisplayFormat.FormatString = "0.0";

            gridView1.MakeColumnInvisible("ProductId");
            gridView1.AddSummary("StokQty", "CikanQty");
            //gridView1.FormatAsPercentage("CikanYuzde");
            gridView2.FormatAsNumber(1, "Qty");
            gridView2.FormatAsDate("GelisTarihi");
            gridView2.AddSummary("Qty");

            gridView1.MakeReadOnly();
            gridView2.MakeReadOnly();

            gleCustomer.Edit.Assign(RI(Rp.V_Customer));
            gleCustomer.EditValueChanged += gleCustomer_EditValueChanged;
            splitContainerControl1.AutoSize();

            gleCustomer.EditValue = 20;
        }

        void gleCustomer_EditValueChanged(object sender, EventArgs e)
        {
            if (intParse(gleCustomer.EditValue) > 0)
            {
                int CustomerId = intParse(gleCustomer.EditValue);
                gridView1.RefreshDataSource(true, "GetAges", CustomerId);
                txtInfo.Caption = AppSession.Lookups.V_Customer.FindByCustomerId(CustomerId).Name;
                gridView1.BestFitColumns();
                gridView2.BestFitColumns();
            }
        }
    }
}
